package org.montecristo.posmobile.rastreo;



import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.Criteria;
import android.location.LocationManager;
import android.os.PowerManager;
import android.widget.Toast;

public class ReciverP extends BroadcastReceiver {
	LocationManager lm;
	@Override
	public void onReceive(Context context, Intent intent) {
		PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);	
		PowerManager.WakeLock wl= pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"hola");
		wl.acquire();
		lm=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
		Localizacion lc=new Localizacion(context, 101,lm,null);	
		lm.requestLocationUpdates(getBestProvider(),0, 0, lc);
		wl.release();	
	
	}

	
	public String getBestProvider(){    	
       	Criteria c = new Criteria();
    	c.setAccuracy(Criteria.ACCURACY_FINE);	    
    	c.setAltitudeRequired(false);
    	c.setBearingRequired(false);
    	c.setCostAllowed(true);
    	c.setPowerRequirement(Criteria.POWER_HIGH);
    	String bestProvider = lm.getBestProvider(c, true);	    	
    	return bestProvider;
   } 	 	
}
